package org.darcy.youchat.activity.me.card;

import android.view.MenuItem;
import android.view.View;

import org.darcy.youchat.R;
import org.darcy.youchat.activity.BaseActivity;
import org.darcy.youchat.databinding.ActivityFriendsCouponBinding;
import org.darcy.youchat.view.CustomDialog;

/**
 * 朋友的优惠券-卡包
 */
public class FriendsCouponActivity extends BaseActivity {

    private ActivityFriendsCouponBinding binding;
    private final String titleName = "朋友的优惠券";

    private CustomDialog mDialog;

    @Override
    public void initView() {
        binding = ActivityFriendsCouponBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        setSupportActionBar(binding.mToolbar.toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle(titleName);
        binding.mToolbar.toolbar.setNavigationIcon(R.mipmap.ic_back);
        showTipDialog();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }



    private void showTipDialog() {
        View view = View.inflate(this, R.layout.dialog_tip_friends_coupon, null);
        mDialog = new CustomDialog(this, view, R.style.dialog);
        mDialog.setCancelable(false);
        mDialog.show();
        view.findViewById(R.id.tvOk).setOnClickListener(v -> {
            mDialog.dismiss();
            mDialog = null;
        });
    }
}